package hms.payment;

import java.sql.*;

import hms.database.*;


/*Using the DBRowObject class, this class passes data from
 * the HMS database to the Cash payment option
 * 
 * @author Edgar Onukwugha*/

public class CashOption extends DBRowObject implements MoneyOption {

	private int payment_method_ID;
	private double cash_amount;
	
	public CashOption(){
		super();
		payment_method_ID = -1;
		cash_amount = 0.00;
	}
	
	/////////////////////////////////////////////////
	/////               SETTERS                //////
	/////////////////////////////////////////////////
		
	public void setPaymentMethodID(int i){
		payment_method_ID = i;
		markAsChanged();
	}
	
	public void setCashAmount(double i){		
		cash_amount = i;
		markAsChanged();
	}
	
	/////////////////////////////////////////////////
	/////               GETTERS                //////
	/////////////////////////////////////////////////
	
	public int getPayemntMethodID(){
		return payment_method_ID;
	}
	
	public double getCashAmount(){
		return cash_amount;
	}
	
	@Override
	protected String[] getFieldNames() {
		// TODO Auto-generated method stub
		String[] output = {
		"PAYMENT_METHOD_ID",
		"CASH_AMOUNT"};
		
		return output;
	}	

	@Override
	protected void loadPreparedStatement(PreparedStatement stmt)
			throws SQLException {
		stmt.setInt(1, payment_method_ID);
		stmt.setDouble(2, cash_amount);
		// TODO Auto-generated method stub
		
	}

	@Override
	protected String getUniqueIdentifierFieldName() {
		// TODO Auto-generated method stub
		return "PAYMENT_ID";
	}

	@Override
	protected String getTableName() {
		// TODO Auto-generated method stub
		return "CASH";
	}

	@Override
	protected void loadFromDatabase(ResultSet rs) throws SQLException {
		this.payment_method_ID = rs.getInt("PAYMENT_METHOD");
		this.cash_amount = rs.getDouble("CASH_AMOUNT");
		
	}

	@Override
	protected boolean allowDuplicateRows() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public double getAmount() {
		return cash_amount;
	}

}
